

from rest_framework import serializers
from goods.models import GoodsVisitCount

# 商品访问量序列化器
class GoodsVisitCountSerializer(serializers.ModelSerializer):
    # 由于接口约定分类对象序列化为名称，所以定义为StringRelatedField
    category = serializers.StringRelatedField()

    class Meta:
        model = GoodsVisitCount
        fields = [
            'category',
            'count'
        ]